package org.hot100_3;

public class leetcode55 {
    public boolean canJump(int[] nums) {

        int n = nums.length;
        if (n==1){
            return true;
        }

        int canJumpIndex = nums[0];

        for (int i = 0; i <=canJumpIndex; i++) {
            canJumpIndex=Math.max(canJumpIndex,i+nums[i]);

            if (canJumpIndex>=n-1){
                return true;
            }
        }

        return false;
    }
}
